package data

import (
	"database/sql"
	"shorturl/pkg/log"
)

const (
	TABLE_URL_MAP      = "url_map"
	TABLE_URL_MAP_USER = "url_map_user"
)

type IUrlMapDataFactory interface {
	NewUrlMapData(isPublic bool) IUrlMapData
}

type UrlMapDataFactory struct {
	log log.ILogger
	db  *sql.DB
}

func NewUrlMapDataFactory(log log.ILogger, db *sql.DB) IUrlMapDataFactory {
	return &UrlMapDataFactory{
		log: log,
		db:  db,
	}
}

func (f UrlMapDataFactory) NewUrlMapData(isPublic bool) IUrlMapData {
	tablename := TABLE_URL_MAP
	if !isPublic {
		tablename = TABLE_URL_MAP_USER
	}
	return NewUrlMapData(f.log, f.db, tablename)
}
